/*dV0UyE4EqLJk1AkxvFM3ymLg7xbMqBslcR2ZmiGzaacfnu44aK/o/Ii6CV+yKpiq*/
import React, { Component } from 'react';
import { base, getMultiLang, createPage } from 'nc-lightapp-front';
import ReferLoader from '../../../public/ReferLoader/index.js';
import { accbookRefcode } from '../../../public/ReferLoader/constants';
const { NCModal, NCButton } = base;
import './index.less';
class AccountingBookModal extends Component {
	constructor(props) {
		super(props);
		this.state = {
			accountbooks: [],
			show: false,
			json: {}
		};
	}

	componentWillMount() {
		let callback= (json) =>{
			this.setState({
				json:json,
			})
		}
		getMultiLang({moduleId:'2002PUBCOMPONENTS',domainName:'gl',currentLocale:'simpchn',callback});
	}
	componentWillReceiveProps(nextProps) {
		let { show, defaultValue } = nextProps;
		let accountbooks = defaultValue;
		if(nextProps.show == this.state.show){
            return;
        }
		this.setState({ show, accountbooks });
		if(nextProps.show){
			this.props.modal.show('account');
		}else{
			this.props.modal.close('account');
		}
	}

	handleConfirm = () => {
		let { accountbooks } = this.state;
		this.props.onConfirm(accountbooks);
	};

	handleClose = () => {
		this.setState({ show: false });
		this.props.onClose();
	};
	modalContent = () => {
		let { accountbooks } = this.state;
		let { context } = this.props;
		return(
			<div className='accountingBookModal'>
				<span className='copy-lable'>{this.state.json['2002PUBCOMPONENTS-000001']/* 国际化处理： 财务核算账簿*/}</span>
				<div className='refer-w'>
					<ReferLoader
						tag="mv2others"
						fieldid='accountbooks'
						value={accountbooks}
						refcode={accbookRefcode}
						placeholder={this.state.json['2002PUBCOMPONENTS-000002']}/* 国际化处理： 复制到其他核算账簿*/
						isMultiSelectedEnabled={true}
						showGroup={false}
						showInCludeChildren={true}
						disabledDataShow = {true}
						queryCondition={() => {
							let condition = {
								TreeRefActionExt: 'nccloud.web.gl.ref.AccountBookRefSqlBuilder',
								"isDataPowerEnable": 'Y',
								"DataPowerOperationCode" : 'fi'
							};
							condition.appcode = context.appcode;
							return condition;
						}}
						onChange={(v) => {
							accountbooks = v;
							this.setState({ accountbooks });
						}}
					/>
				</div>
			</div>
		)
	}
	render() {
		let { modal } = this.props;
		return (
			<div>
				{modal.createModal('account', {
					title: this.state.json['2002PUBCOMPONENTS-000000'], /* 国际化处理： 复制到*/
					size: 'sm',
					content: this.modalContent(), //弹框内容，可以是字符串或dom
					beSureBtnClick: this.handleConfirm,//点击确定按钮事件
					cancelBtnClick: this.handleClose, //取消按钮事件
					closeModalEve: this.handleClose, //关闭按钮事件回调
				})}
			</div>
		);
	}
}

AccountingBookModal = createPage({})(AccountingBookModal);
export default AccountingBookModal;


/*dV0UyE4EqLJk1AkxvFM3ymLg7xbMqBslcR2ZmiGzaacfnu44aK/o/Ii6CV+yKpiq*/